package com.ruoyi.h5.controller;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.MiniSelfSelection;
import com.ruoyi.system.service.h5.MiniSelfSelectionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 自选
 * @author :liding
 * @date : 2023/11/19 17:20
 */
@RestController
@RequestMapping("/self")
@Slf4j
@Anonymous
public class SelfSelectionController {
    @Autowired
    private MiniSelfSelectionService miniSelfSelectionService;

    /**
     * 添加自选
     * @param selfSelection
     * @return
     */
    @PostMapping
    public AjaxResult add(@RequestBody MiniSelfSelection selfSelection){
        return miniSelfSelectionService.add(selfSelection);
    }

    /**
     * 自选列表
     * @param type
     * @param openid
     * @return
     */
    @GetMapping("list")
    public AjaxResult list(@RequestParam("type")String type,@RequestParam("openid")String openid){
        return miniSelfSelectionService.selectionList(type, openid);
    }
    /**
     * 取消自选
     * @param type 自选类型  1：股票 2：题材
     * @param id 股票id或者题材id
     * @param openid openid
     * @return
     */
    @GetMapping("disabled")
    public AjaxResult disabled(@RequestParam("type")String type,
                               @RequestParam("openid")String openid,
                               @RequestParam(value = "id", required = false)Long id,
                               @RequestParam(value = "stockNo", required = false)String stockNo) {
        return miniSelfSelectionService.disabled(id, openid, type, stockNo);
    }
    /**
     * 检查是否添加到自选了
     * @param type 自选类型  1：股票 2：题材
     * @param id 股票id或者题材id
     * @param openid openid
     * @return
     */
    @GetMapping("check")
    public AjaxResult<Integer> check(@RequestParam("type")String type,
                                     @RequestParam("openid")String openid,
                                     @RequestParam(value = "id", required = false)Long id,
                                     @RequestParam(value = "stockNo", required = false)String stockNo){
        return miniSelfSelectionService.check(type,openid,id,stockNo);
    }
}
